1. Field of the Invention
This invention relates to virtualization and the use of virtual machines in processors and computer systems and, more particularly, to limiting guest execution in a processor/computer system implementing virtualization.
2. Description of the Related Art
Virtualization has been used in computer systems for a variety of different purposes. For example, virtualization may be used to execute privileged software in a “container” to prevent the privileged software from directly accessing and/or making changes to at least some of the physical machine state without first being permitted to do so by a virtual machine manager (VMM) that controls the virtual machine. Such a container may prevent “buggy” or malicious software from causing problems on the physical machine. Additionally, virtualization may be used to permit two or more privileged programs to execute on the same physical machine concurrently. The privileged programs may be prevented from interfering with each other since access to the physical machine is controlled. Privileged programs may include operating systems, and may also include other software which expects to have full control of the hardware on which the software is executing. In another example, virtualization may be used to execute a privileged program on hardware that differs from the hardware expected by the privileged program.
Generally, virtualization of a processor or computer system may include providing one or more privileged programs with access to a virtual machine (the container mentioned above) over which the privileged program has full control, but the control of the physical machine is retained by the VMM. The virtual machine may include a processor (or processors), memory, and various peripheral devices that the privileged program expects to find in the machine on which it is executing. Each privileged program (and related software in some cases, such as the applications that execute on an operating system) may be referred to herein as a guest. Virtualization may be implemented in software (e.g. the VMM mentioned above) without any specific hardware virtualization support in the physical machine on which the VMM and its virtual machines execute. However, virtualization may be simplified and/or achieve higher performance if some hardware support is provided.
Generally, both the VMM and the guests may execute on the physical processors in the computer system. The VMM may schedule a guest for execution, cause the guest's state to be loaded into the physical processor, and start execution of the guest on the processor. The guest's instructions are then executed by the processor (the guest is “in control” of the processor). The VMM may thus require a mechanism to recover control of the physical processor.
Typically, the VMM uses an external interrupt timer to recover control of the processor. The timer is programmable with a time interval, and at the expiration of the time interval the timer interrupts the processor (using an external interrupt signal on the processor). The external interrupt timer is typically limited to measuring time. Additionally, the external interrupt timer may not be a very accurate measure of guest execution time, as the timer is setup by the VMM and begins timing prior to beginning execution of the guest. The location of the external interrupt timer in the computer system and configuring the timer may be platform dependent, and thus may vary from system to system. Additionally, the guest operating system (or other privileged code in the guest) may in fact expect to use such an external timer itself, since such a timer typically exists in the PC platform. In such cases, it would be necessary to virtualize the timer, such that VMM and guest can share it.